<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<script type="text/javascript" charset="utf-8"
		src="<%=basePath%>ueditor/editor_all.js"></script> 
<script type="text/javascript" charset="utf-8"
		src="<%=basePath%>ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" charset="utf-8"
		src="<%=basePath%>ueditor/editor_config.js"></script>
		<c:if test="${message }">
		  <div style="width:98%; height:50px;">
		            <strong> 添加成功</strong>
		  </div>  
		</c:if>
		<c:if test="${update }">
		  <div style="width:98%; height:50px;">
		            <strong> 修改成功</strong>
		  </div>  
		</c:if>
<form action="<%=basePath %>backend/updateScienceDirection" class='form-horizontal' method="post" id='ScienceDirectionForm'>
			
           <div class="row div-common">
          <div class="span6 input-prepend" >
                 <span class="add-on">科研方向名称</span>
                 <input id='title' type="text" name="directionName" value="${direction.directionName }">
              <span></span>
              </div> 
              </div>
              <div class="row">
          <div class="span10 control-group" style='margin-top:10px;margin-left:15px;'>
                 <label class="control-label" >负责人：</label>
                 <div class='controls'>
                   <table class='table table-bordered'>
                       <c:forEach begin="1" end="${fn:length(teachers)}" step="6" varStatus="status">
                           <tr class="row-fluid">
                            <c:forEach items="${teachers }" var="cteacher" begin="${(status.count-1)*6 }" end="${(status.count)*6-1 }">        
                               <td>
                                  <input type="checkbox"  value='${cteacher.id }' id='leader${cteacher.id }' class='fzcheckbox' />
                                  ${cteacher.name }
                               </td>
                          </c:forEach>
                      </tr>
                   </c:forEach>
                   
                    </table>
                 </div>
              <span></span>
              </div>
              
              <div class="span10 control-group" style='margin-top:10px;margin-left:15px;'>
                 <label class="control-label" >团队成员：</label>
                 <div class='controls'>
                 <table class='table table-bordered'>
                       <c:forEach begin="1" end="${fn:length(teachers)}" step="6" varStatus="status">
                           <tr class="row-fluid">
                            <c:forEach items="${teachers }" var="cteacher" begin="${(status.count-1)*6 }" end="${(status.count)*6-1 }">        
                               <td>
                                  <input type="checkbox" value='${cteacher.id }' id='member${cteacher.id }' class='tdcheckbox' />
                                  ${cteacher.name }
                               </td>
                          </c:forEach>
                      </tr>
                   </c:forEach>
                   
                    </table>
                    </div>
              <span></span>
              </div> 
              </div>
            <div class='row div-common' >
                <h3>方向简介：</h3>
              <div style='margin-top: 10px;'>
			  
		       <script  id="editor" ></script>
		       </div>
            </div>
		      <div class='row div-common' >
		       <h3>  成果：</h3>
			  <div style='margin-top: 10px;'>
			  
		       <script  id="editor1" ></script>
		       </div>
		      </div>
	    <!-- <input type="checkbox" value="0" name='index' id='index'  />首页新闻 -->
		<input  type="submit" value="完成" style="margin-left: 600px;margin-top: 10px;" class="btn btn-info" onclick="return getContent();"/></div>
		<input id="intro" type="hidden" name="directionIntro" value="${direction.directionIntro }">
		<input id="plan" type="hidden" name="directionAchievement" value="${direction.directionAchievement }">
		<input id='ids' name='ids' type="hidden" >
		<input id='ids1' name='ids1' type="hidden" >
		<input id='' name='directionId' value='${direction.directionId }' type="hidden" >
		<c:forEach items="${leaders }" var='i'>
		    <input  class='leaders' id='' type="hidden" value="${i.tId.id}" />
		</c:forEach>
		<c:forEach items="${members }" var='i'>
		    <input  class='members' id='' type="hidden" value="${i.tId.id}" />
		</c:forEach>
	</form>
	
	<script type="text/javascript">
	var editor = new UE.ui.Editor();
    editor.render("editor");
    var editor1 = new UE.ui.Editor();
    editor1.render("editor1");
    $(function(){
		var content = $("#intro").val();
		var majorPlan = $("#plan").val();
         editor.ready(function(){
           editor.setContent(content);
          });
         editor1.ready(function(){
             editor1.setContent(majorPlan);
            });
    });
    $(".leaders").each(function(){
    	var leaderid ="#leader"+$(this).val();
    	//alert(leaderid);
	    $(leaderid).attr("checked","checked");
	});
    $(".members").each(function(){
    	var membersid = "#member"+$(this).val();
    	//alert(membersid);
    	$(membersid).attr("checked","checked");
    });
    
    var ue = UE.getEditor('editor');
	var ue1 = UE.getEditor('editor1');
    function getContent() {
        var str= ue.getContent();
        var plan = ue1.getContent();
       // alert(str);
        //document.getElementById('content').value=str;
        $("#intro").val(str);
        $("#plan").val(plan);
        var str="";
        var plan="";
        var id = "";
        $(".fzcheckbox").each(function(){
        	if($(this).attr("checked") == true || $(this).attr("checked") == "checked")
			  {
        		
				 id+=","+$(this).val();
			  }
        });
        var id1 = "";
        $(".tdcheckbox").each(function(){
        	if($(this).attr("checked") == true || $(this).attr("checked") == "checked")
			  {
        		
				 id1+=","+$(this).val();
			  }
        });
       // alert(id+"----id");
        //alert(id1+"----id1");
        $("#ids").val(id);
        $("#ids1").val(id1);
        
        
        return true;
    };
  
</script>
